<template>
  <div>
    <el-col>
      <h5 style="text-align: center; background-color: rgb(103, 162, 239); margin: 0; font-size: 20px; padding: 20px 0; color: white"><img src="../assets/ll.png" style="width: 40px; height: 40px" alt="" /> OA管理系统</h5>
      <el-menu default-active="2"  @open="handleOpen" @close="handleClose" :collapse="isCollapse" class="el-menu-vertical-demo"  style="border: 1px solid rgb(103, 162, 239);" background-color="rgb(103, 162, 239)" text-color="white"  router>
        <!-- 包个span标签然后遍历， -->
        <span v-for="(item, index) in ceb" :key="item.id">
          <!-- 先弄一个el-menu-item ，然后判断他的children有没有长度，没长度的话显示，有长度隐藏 -->
          <el-menu-item v-if="item.children.length == 0" :index="item.path">
            <i class="el-icon-location"></i>
            <span>{{ item.caidan }}</span>
          </el-menu-item>

          <!-- 有长度的话在这里能下拉的显示，这个要加toString（） -->
          <el-submenu :index="item.id.toString()" v-else>
            <template slot="title">
              <i class="el-icon-location"></i>
              <span>{{ item.caidan }}</span>
            </template>
            <el-menu-item-group v-for="(item1, index1) in item.children" :key="item1.id" >
              <el-menu-item :index="item1.path" style="color: white">{{ item1.caidan }}</el-menu-item>
            </el-menu-item-group>
          </el-submenu>
        </span>
      </el-menu>
    </el-col>
  </div>
</template>
<script>
import axios from 'axios'
export default {
  data() {
    return {
      ceb: [],
      isCollapse:false
    }
  },
  mounted() {
    this.ce()
  },
  methods: {
    ce() {
      axios.get('/effect/user/side').then((res) => {
        this.ceb = res.data.side
        console.log(res)
      })
    },

    handleOpen(key, keyPath) {
      console.log(key, keyPath)
    },
    handleClose(key, keyPath) {
      console.log(key, keyPath)
    }
  }
}
</script>
<style scoped>
  .el-col{
    width: 14%;
  height: 100%;
  /* border: 1px solid red; */
  position: fixed;
  } 
  .el-menu{
  /* width: 10%; */
  height: 100%;
  background-color: rgb(103, 162, 239);
  /* position: fixed; */
  }
  
</style>